package com.cuit.dao;

import com.cuit.doamin.Staff;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface StaffDao {
    /**
     * 查询所有员工
     *
     * @return
     */
    @Select("select * from staff")
    public List<Staff> findAll();

    /**
     * 模糊查询职位
     *
     * @return
     */
    @Select("select * from staff where s_position like #{position}")
    public List<Staff> findPosition(String position);

    /**
     * 添加员工
     *
     * @return
     */
    @Insert("insert into staff (s_name,s_age,s_sex,s_salary,s_position,s_d_id) " +
            "values(#{s_name},#{s_age},#{s_sex},#{s_salary},#{s_position},#{s_d_id})")
    public boolean add(Staff staff);

    /**
     * 删除一个员工
     *
     * @return
     */
    @Delete("delete from staff where s_id = #{id}")
    public boolean delete(Integer id);

    /**
     * 修改一个员工
     *
     * @return
     */
    @Update("update staff set s_name = #{s_name},s_age = #{s_age},s_sex = #{s_sex},s_salary = #{s_salary},s_position = #{s_position},s_d_id = #{s_d_id} where s_id = #{s_id}")
    public boolean update(Staff staff);
}
